/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef DEVICES_BLUETOOTH_H
#define DEVICES_BLUETOOTH_H


/* Includes ------------------------------------------------------------------*/
#include "Devices_E22.h"
#include "stdarg.h"
#include "stdio.h"

/* Exported constants --------------------------------------------------------*/
#define BlueTooth_BufferLength 30

#define BlueTooth_SendMessageLength 18

/* Exported macros -----------------------------------------------------------*/
/* Receive Bluetooth Config */
#define BlueTooth_CMD_Enable() \
HAL_GPIO_WritePin(REC_BTE_CMD_GPIO_Port,REC_BTE_CMD_Pin,GPIO_PIN_SET)
#define BlueTooth_CMD_Disable() \
HAL_GPIO_WritePin(REC_BTE_CMD_GPIO_Port,REC_BTE_CMD_Pin,GPIO_PIN_RESET)

#define BlueTooth_RST_Enable() \
HAL_GPIO_WritePin(REC_BTE_RST_GPIO_Port,REC_BTE_RST_Pin,GPIO_PIN_SET)
#define BlueTooth_RST_Disable() \
HAL_GPIO_WritePin(REC_BTE_RST_GPIO_Port,REC_BTE_RST_Pin,GPIO_PIN_RESET)

/* ====== Bluetooth Command ====== */

/* Serial Port Profile Config */
/* If Serial Port Profile is Visible :Open(1) Close(0) */
#define BT_SPP_CONFIG "AT+SPP=1\r\n"
/* Serial Port Profile Visible name */
#define BT_SPP_NAME "AT+DNAME=JZI-MXN-LY30\r\n"

/* Bluetooth low Energy Config */
/* If Bluetooth low Energy is Visible :Open(1) Close(0) */
#define BT_BOARDCAST_CONFIG "AT+BLE=0\r\n"
/* Bluetooth low Energy Name */
#define BT_BOARDCAST_NAME "AT+LENAME=JZI-MXN-LY30\r\n"

/* Pairing Config */
/* If Bluetooth Pairing is Visible :Open(1) Close(0) */
#define BT_PAIRING_CONFIG "AT+PINE=1\r\n"
/* Bluetooth Pairing Password */
#define PIN_CONF  "AT+PIN=1234\r\n"

/* Activate Bluetooth */
#define VRE_SEARCH "AT+VER?\r\n"
#define PIN_SEARCH "AT+PIN?\r\n"
														 
#define BlueTooth_FucGroundInit \
{ \
	&REC_BlueTooth_USART_IT_Register, \
	&REC_BlueTooth_Mode_Setting, \
	&REC_BlueTooth_Set_Name, \
	&BlueTooth_Send_App, \
	&BlueTooth_Send_AppOld, \
	&huart5, \
}


/* Exported types ------------------------------------------------------------*/


typedef struct
{
	void(*REC_BlueTooth_USART_IT_Register)(UART_HandleTypeDef* huartx);
	void(*REC_BlueTooth_Mode_Setting)(void);
	void(*REC_BlueTooth_Set_Name)(uint8_t *p,uint8_t len);
	void(*BlueTooth_Send_App)(char* Fake_ATCommand);
	void(*BlueTooth_Send_AppOld)(uint8_t* Fake_ATCommandOld);
	UART_HandleTypeDef *BlueTooth_Register;
}BlueTooth_Fuc;

/* Exported variables --------------------------------------------------------*/
extern BlueTooth_Fuc BlueTooth_Function;
/* End -----------------------------------------------------------------------*/
#endif
